package com.kaifamiao.dispatch;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.logging.Logger;

@WebServlet( "/include/image" )
public class IncludeImageServlet extends HttpServlet {

    private Logger logger = Logger.getLogger( this.getClass().getName() ) ;

    @Override
    protected void service(HttpServletRequest request , HttpServletResponse response)
            throws ServletException, IOException {
        logger.info( "测试包含图片文件(字节数据)" );

        response.setContentType( "image/jpeg" );
        response.setHeader( "content-disposition" , "inline" );

        String path = "/WEB-INF/fengjie.jpg" ;
        RequestDispatcher dispatcher = request.getRequestDispatcher( path );
        dispatcher.include( request , response );

    }

}
